<?php
declare(strict_types= 1);

use app\admin\model\ArcModel;
use app\admin\model\ArcModelField;

use function PHPUnit\Framework\assertTrue;

use app\admin\service\ModelServiceImpl;

use think\App;

class ModelTest extends PHPUnit\Framework\TestCase{
    public static function setUpBeforeClass(): void
    {
        $http = (new App())->http;

        $response = $http->run();
    }

    function tearDown(): void
    {
        assertTrue(true);
    }
    public function testAdd()
    {
        try {
            //code...
            $service =  new ModelServiceImpl();
            $service->add("Bbbbb","bbbbb");
        } catch (\Throwable $th) {
            //throw $th;
            print("error");
            print(PHP_EOL);
            print($th->getMessage());
        }
       
    }
    public function testfiled_delete(){
        try {
            //code...
            $service =  new ModelServiceImpl();
            $service->filed_delete(2);
        } catch (\Throwable $th) {
            print("error");
            print(PHP_EOL);
            print($th->getMessage());
        } 
    }
    public function testUpdate(){
        try {
            //code...
            $service =  new ModelServiceImpl();
            $service->filed_add(2,"fffff",ArcModelField::FIELD_TYPE__VARCHAR_255,ArcModelField::DATA_TYPE__STRING,"ffff");
            // $service->filed_edit(2,8,"cccc",ArcModelField::FIELD_TYPE__VARCHAR_255,ArcModelField::DATA_TYPE__STRING,"aaaaaaa");
        } catch (\Throwable $th) {
            //throw $th;
            print("error");
            print(PHP_EOL);
            print($th->getMessage());
        } 
    }
    public function testGet(){
        // print(ArcModelField::MYSQL_TYPE__VARCHAR_255);
        // var_dump(ArcModelField::MYSQL_TYPES);
        // var_dump(in_array(ArcModelField::MYSQL_TYPE__VARCHAR_255, ArcModelField::MYSQL_TYPES));
    }
    public function testEdit(){
        try {
            //code...
            $service =  new ModelServiceImpl();
            $service->edit(3,"Ccccc","cccc");
        } catch (\Throwable $th) {
            //throw $th;
            print("error");
            print(PHP_EOL);
            print($th->getMessage());
        }
    }
    public function testModel()
    {
        $model = new ArcModel();
        $model->name = "aaa";
        $model->save();
    }
    
}
